<template>
	<view class="tabbar" :style="{'padding-bottom': paddingBottomHeight + 'rpx'}">


		<view class="tabbar-item" v-for="(item, index) in list" :key="index" @click="tabbarChange(item.path)">
			<image class="item-img " :src="item.icon_a" v-if="current == index"></image>
			<image class="item-img weixuan" :src="item.icon" v-else></image>
			<view class="item-name" :class="{'tabbarActive': current == index}" v-if="item.text">{{item.text}}</view>


		</view>
		<view class="fumore" v-if="showMore" @click="yincs">
			<view class="jiw"></view>
			<view @click="tabermore(item.pathss)" class="fpw" v-for="(item, index) in listooo" :key="index">
				{{item.text}}
			</view>
		</view>



	</view>
</template>

<script>
	export default {
		props: {
			current: String,
		},
		data() {
			return {
				vusw: 3,
				showMore:false,
				paddingBottomHeight: 0, //苹果X以上手机底部适配高度
				list: [{
					clickCount: 0,
					text: '首页',
					icon: '../static/tabBar/taber1.png', //未选中图标
					icon_a: '../static/tabBar/taber01.png', //选中图片
					path: "index", //页面路径
				}, {
					clickCount: 1,
					text: '公司介绍',
					icon: '../static/tabBar/taber2.png',
					icon_a: '../static/tabBar/taber02.png',
					path: 'about',
				}, {
					clickCount: 2,
					text: '了解加盟',
					icon: '../static/tabBar/taber3.png',
					icon_a: '../static/tabBar/taber03.png',
					path: "user",
				}, {
					clickCount: 3,
					text: '咨询加盟',
					icon: '../static/tabBar/taber4.png',
					icon_a: '../static/tabBar/taber04.png',
					path: "zixun",
				}],
				// 1、答疑：https://static.pagoda.com.cn/franchiseeGzh/#/answer
				// 2、申请加盟：https://static.pagoda.com.cn/franchiseeGzh/#/applyTab
				// 3、在线客服：https://static.pagoda.com.cn/franchiseeGzh/#/answer
				// 4、企业微信：https://landing.weiling.cn/baiguoyuan.html?channel=mp
				listooo: [{
					text: '问题答疑',
					pathss: "https://franchisee-gzh.jmsfwglxt.huawei-prod.pagoda.com.cn/#/answer",
				}, {
					text: '在线客服',
					pathss: "https://kfyw.pagoda.com.cn/webchatbot/h5chat_pagoda.html?sysNum=1638265220559&sourceId=105&lang=zh_CN&wxOrg=gh_2b0827267a5a&openid=o3QNIwdoWsUYqNEoNbIjiUZxLfdM&encrypt=false&_dc=1660631830622#reloaded",
				}, {
					text: '申请加盟',
					pathss: "https://franchisee-gzh.jmsfwglxt.huawei-prod.pagoda.com.cn/#/applyTab",
				}, {
					text: '进驻城市',
					pathss: "https://static.pagoda.com.cn/franchiseeGzh/#/enteringCity",
				}]
			};
		},
		created() {
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
					model.forEach(item => {
						//适配iphoneX以上的底部，给tabbar一定高度的padding-bottom
						if (res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
							that.paddingBottomHeight = 40;
						}
					})
				}
			});
		},
		methods: {
			tabbarChange(path) {
				
				if (path == 'zixun') {
					this.showMore=!this.showMore
					// if(this.vusw == 3){
					// 	this.vusw = 5
					// }else{
					// 	this.vusw = 3
					// }
					return
				}
				uni.switchTab({
					url: `/pages/${path}/index`,
				})
			},
			tabermore(pathss) {

				if (pathss == 'zixun') {
					uni.switchTab({
						url: `/pages/${pathss}/index`,

					})
				} else {
					uni.navigateTo({
						url: `/pages/webview/index?src=${encodeURIComponent(pathss)}`
					})
				}
			},
			yincs() {
				console.log(this.vusw);
				this.showMore=false
			},

		},
	};
</script>

<style lang="scss" scoped>
	.tabbarActive {
		color: #79D5AD !important;
	}

	.tabbar {
		padding-top: 10rpx;
		border-radius: 20rpx 20rpx 0 0;
		position: fixed;
		z-index: 1000;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		justify-content: space-around;
		align-items: center;
		width: 100%;
		height: 100rpx;
		background-color: #ffffff;
		overflow: visible;

		.tabbar-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
			height: 100rpx;

			.item-img {
				margin-bottom: 4rpx;
				width: 46rpx;
				height: 46rpx;
			}

			.item-name {
				font-size: 26rpx;
				color: #A3A3A3;
			}

			.weixuan {
				width: 40rpx;
				height: 40rpx;
				padding-bottom: 7rpx;
				padding-right: 5rpx;
			}
		}

	}


	.fumore {
		position: absolute;
		right: 4%;
		top: -170%;
		z-index: 1000;
		background: #fff;
		border-radius: 10rpx;
		padding: 10rpx 20rpx;
		overflow: visible;

		.jiw {
			position: absolute;
			border: 10px solid #0000;
			border-top-color: #fff;
			width: 0;
			height: 0;
			bottom: -35rpx;
			left: 0;
			right: 0;
			margin: auto;
		}

		.fpw {
			font-size: 26rpx;
			color: #A3A3A3;
			line-height: 2;
		}
	}
</style>